<template>
  <section class="my-fleadetail">
    <div
      class="task flex flex-between"
    >
      <div class="left flex">
        <img
          :src="info.frontImgUrl"
        >
        <div class="flex-col flex-between content-text">
          <div class="title">{{info.productName}}</div>
          <div class="status">{{typeOption[info.quality]}}</div>
          <div class="price">￥{{info.price}}</div>
        </div>
      </div>
      <div class="right flex-col flex-bottom">
        <div class="status">{{info.displaceGoodsClass == 1?'置换':'出售'}}</div>
        <div class="mt15 num">X{{info.nums}}</div>
      </div>
    </div>
    <div class="detail">
      <div class="text">
        {{info.productDtl}}
      </div>
      <Swiper :images="info.imgList" />
    </div>
    <button class="btn" @click="handleIm(info.memberId)" v-if="memberId != info.memberId">联系卖家</button>
  </section>
</template>
<script>
import Swiper from "@/components/swiper";
export default {
  components: { Swiper },
  data() {
    return {
      productId:'',
      info:'',
      typeOption: {
        1: '全新',
        2: '九成新',
        3: '八成新',
        4: '七成新',
        5: '六成新',
        6: '五成新'
      },
      memberId: wx.getStorageSync('memberId')
    };
  },
  onLoad(e) {
    this.productId = e.id?e.id:40;
    this.fleaselectProductDetail()
  },
  methods: {
    preImg(url) {
      console.log(url);
      let urls = this.info.imgList.map((item) => {
        return item.imageUrl
      })
      wx.previewImage({
        current: url, // 当前显示图片的http链接
        urls // 需要预览的图片http链接列表
      })
    },
    routerTo(id) {
      wx.navigateTo({ url: "../fleadetail/main?id=" + id });
    },
    fleaselectProductDetail(){
      this.$api.fleaselectProductDetail({productId:this.productId}).then(res=>{
        let imgList = res.data.product.imgList.map(item=>{
          item.url = item.imageUrl;
          return item;
        })
        res.data.product.imgList = imgList;
        this.info = res.data.product;
      })
    },
    handleIm(id) {
      this.$tim(id);
    }
  }
};
</script>
<style lang="scss" scoped>
.my-fleadetail {
  .task {
    background: white;
    padding: 25px 15px;
    background: rgba(255, 255, 255, 1);
    border-radius: 4px;
    .left {
      img {
        width: 70px;
        height: 70px;
        border-radius: 2px;
        margin-right: 10px;
      }
      .titile {
        font-size: 15px;
        font-family: PingFang;
        font-weight: 500;
        color: rgba(46, 46, 46, 1);
        line-height: 21px;
      }
      .status {
        font-size: 12px;
        font-family: PingFang;
        font-weight: 500;
        color: rgba(193, 196, 201, 1);
        width: 45px;
        height: 18px;
        line-height: 18px;
        text-align: center;
        background: rgba(247, 247, 247, 1);
        border-radius: 2px;
      }
      .price {
        font-size: 15px;
        font-family: PingFang;
        font-weight: 400;
        color: rgba(255, 156, 0, 1);
        line-height: 22px;
      }
    }
    .right {
      width: 100px;
      .status {
        padding: 3px 6px;
        border: 1px solid rgba(59, 184, 253, 1);
        border-radius: 2px;
        font-size: 12px;
        font-family: PingFang;
        font-weight: 500;
        color: rgba(59, 184, 253, 1);
      }
      .num {
        font-size: 15px;
        font-family: PingFang;
        font-weight: 500;
        color: rgba(193, 196, 201, 1);
        line-height: 36px;
      }
    }
  }
  .detail {
    margin-top: 10px;
    padding: 15px;
    background: white;
    .text {
      font-size: 12px;
      font-family: PingFang;
      font-weight: 500;
      color: rgba(46, 46, 46, 1);
      line-height: 21px;
      margin-bottom: 15px;
    }
  }
  .btn {
    margin: 30px auto;
    width: 345px;
    height: 44px;
    line-height: 44px;
    background: rgba(59, 184, 253, 1);
    border-radius: 5px;
    font-size: 15px;
    font-family: PingFang;
    font-weight: 500;
    color: rgba(255, 255, 255, 1);
  }
}
.content-text {
  flex: 1;
}
</style>
<style lang="scss">
page {
  background: #f7f7f7;
}
</style>